﻿package com.wandian.controller
{
	import com.wandian.data.GameData;
	import com.wandian.model.AccountProxy;
	import com.wandian.model.socket.ServerPacketProxy;
	import com.wandian.model.vo.PlayerVo;
	import com.wandian.model.vo.RoomVo;
	import com.wandian.view.mediator.GameRoomMediator;
	import com.wandian.view.mediator.MaskGameMediator;
	import com.wandian.view.mediator.account.AccountMediator;
	
	import flash.display.MovieClip;
	
	import org.puremvc.as3.interfaces.*;
	import org.puremvc.as3.patterns.command.*;
	/**   
	* @author long
	* @QQ 108232706
	* @version 1.0   
	*/   
	public class AccountCommand extends SimpleCommand
	{
		private var _global:GameData;
		private var accountPanel:MovieClip;
		public function AccountCommand()
		{
			this._global=GameData.getInstance();
			
			return;
		} 

		override public function execute(notification:INotification):void
		{
			var playerVo:PlayerVo=null;
			super.execute(notification);
			switch (notification.getName())
			{
				case CLZNoticeName.SHOW_ACCOUNT:
				{
					playerVo=notification.getBody() as PlayerVo;
					this.showAccount(notification, CLZNoticeName.SHOW_ACCOUNT, playerVo);
					break;
				}
				case CLZNoticeName.USEPROPS_BTN:
				{
					playerVo=notification.getBody() as PlayerVo;
					this.showAccount(notification, CLZNoticeName.USEPROPS_BTN, playerVo);
					break;
				}
				case CLZNoticeName.ACHIEVEMENT_BTN:
				{
					playerVo=notification.getBody() as PlayerVo;
					this.showAccount(notification, CLZNoticeName.ACHIEVEMENT_BTN, playerVo);
					break;
				}
				case CLZNoticeName.MY_PROP_LIST_REQ:
				{
					(facade.retrieveProxy(AccountProxy.NAME) as AccountProxy).requestMyPropList();
					break;
				}
				case CLZNoticeName.MY_HONOR_REQ:
				{
					(facade.retrieveProxy(AccountProxy.NAME) as AccountProxy).requestMyHonor(notification.getBody() as uint);
					break;
				}
				case CLZNoticeName.PLAYER_INFOMATION_REQ:
				{
					(facade.retrieveProxy(AccountProxy.NAME) as AccountProxy).requestInfomation(notification.getBody() as uint);
					break;
				}
				case CLZNoticeName.WEALTH_RECORD_REQ:
				{
					(facade.retrieveProxy(AccountProxy.NAME) as AccountProxy).requestWealthRecord();
					break;
				}
				default:
				{
					break;
				}
			}
			return;
		} 

		private function showAccount(notification:INotification, strInitShowType:String, playerVo:PlayerVo):void
		{
			if (!this.accountPanel)
			{
				this.accountPanel=GameData.getMovieClip("AccountPanel");
			}
			if (!Texas.I._mcWindosView.contains(this.accountPanel))
			{
				Texas.I._mcWindosView.addChildTo(this.accountPanel);
				Texas.I._mcWindosView.centerXY(this.accountPanel, 0, 7);
			}
			facade.registerMediator(new AccountMediator(this.accountPanel, strInitShowType, playerVo, notification.getType()));
			return;
		} 

	}
}
